#ifndef BLEPACKET_HPP
#define BLEPACKET_HPP
#include <stdint.h>

#define MAX_LE_SYMBOLS 64
#define LE_ADV_AA 0x8E89BED6

#define LE_DEWHITENED        0x0001
#define LE_SIGPOWER_VALID    0x0002
#define LE_NOISEPOWER_VALID  0x0004
#define LE_PACKET_DECRYPTED  0x0008
#define LE_REF_AA_VALID      0x0010
#define LE_AA_OFFENSES_VALID 0x0020
#define LE_CHANNEL_ALIASED   0x0040
#define LE_CRC_CHECKED       0x0400
#define LE_CRC_VALID         0x0800
#define LE_MIC_CHECKED       0x1000
#define LE_MIC_VALID         0x2000

#define LE_MAX_PAYLOAD       48

struct lell_packet {
	// raw unwhitened bytes of packet, including access address
	uint8_t symbols[MAX_LE_SYMBOLS];

	uint32_t access_address;

	// channel index
	uint8_t channel_idx;
	uint8_t channel_k;

	// number of symbols
	int length;

	uint32_t clk100ns;

	// advertising packet header info
	uint8_t adv_type;
	int adv_tx_add;
	int adv_rx_add;

	unsigned access_address_offenses;
	uint32_t refcount;

	/* flags */
	union {
		struct {
			uint32_t access_address_ok : 1;
		} as_bits;
		uint32_t as_word;
	} flags;
};

typedef struct _pcap_bluetooth_le_ll_header {
	uint8_t rf_channel;
	int8_t signal_power;
	int8_t noise_power;
	uint8_t access_address_offenses;
	uint32_t ref_access_address;
	uint16_t flags;
	uint8_t le_packet[LE_MAX_PAYLOAD];
} pcap_bluetooth_le_ll_header;


#endif


